<template>
  <van-nav-bar
    :title="title"
    left-text="返回"
    right-text="按钮"
    left-arrow
    @click-left="onClickLeft"
    @click-right="onClickRight"
    :placeholder="true"
    :fixed="true"
  >
    <template #right>
      <van-icon name="more-o" size="30" />

      <van-popover
        v-model="showPopover"
        trigger="click"
        :actions="actions"
        @select="clickOneDone"
      >
        <template #reference> </template>
      </van-popover>
    </template>
  </van-nav-bar>
</template>
<script>
export default {
  props: {
    title: String,
  },
  data() {
    return {
      showPopover: false,
      true: true,
      actions: [
        { text: "搜索", icon: "search", name: "search" },
        { text: "登录", icon: "cashier-o", name: "login" },
        { text: "扫一扫", icon: "camera", name: "carema" },
      ],
    };
  },
  methods: {
    onClickLeft() {
      console.log(this.$router);
      console.log(this.$router.go(-1));
    },
    onClickRight() {
      this.showPopover = !this.showPopover;
    },
    clickOneDone(actions) {
      if (this.$router.name != actions.name) {
        this.$router.push({ name: actions.name });
      }
    },
  },
};
</script>
<style lang="scss" >

.van-popover {
  right: 0;
  width: 180px;
  top: 45px !important;
}
</style>